package cn.taobaoke.restful.domain;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * @author yangzuo
 * @since 2017-03-15
 */
@Deprecated
@Repository
public interface OrderRepository extends JpaRepository<OrderEntity, Long> {

    @Query("from OrderEntity entity where (entity.orderNumber like %:keyword% or entity.commodityInfo like %:keyword%) and ( entity.grandParentId = :agentId or entity.parentId = :agentId or entity.promoterId = :agentId )")
    Page<OrderEntity> findOrdersForAgentByKeyword(@Param("agentId") Long agentId, @Param("keyword") String keyword, Pageable pageable);

    OrderEntity findByOrderNumber(String orderNumber);

    @Query("from OrderEntity entity where (entity.orderNumber like %:keyword% or entity.commodityInfo like %:keyword%)")
    Page<OrderEntity> findOrdersByKeyword(@Param("keyword") String keyword, Pageable pageable);
}
